TOOLS-4071 Fix mongorestore collMod an index lacking options#883
TOOLS-4071 Fix mongorestore collMod an index lacking options#883
Conversation
FGasper
left a comment
There was a problem hiding this comment.
This sort of “deny-list” approach seems out of step with our usual stance of vetting anything we send to the destination.
Discussed over DM that it should be an allow-list instead (like mongosync).
common/idx/index_catalog.go
Outdated
| expireValue, | ||
| indexMod, | ||
| ) | ||
| for k, v := range bsonutil.ToMap(indexMod) { |
There was a problem hiding this comment.
Nit: why ToMap here? It seems almost as easy to iterate the bson.D.
FGasper
left a comment
There was a problem hiding this comment.
It looks like there’s an internal discrepancy here … ?
| if expireKeyError != nil && hiddenKeyError != nil { | ||
| return errors.Errorf("must specify expireAfterSeconds or hidden: %v", indexMod) | ||
| } else { | ||
| return errors.Errorf("unknown index option: %v", k) |
There was a problem hiding this comment.
How does this logic square with the validIndexOptions in common/bsonutil/indexes.go? It seems like there are many more attributes than are listed here.
There was a problem hiding this comment.
I'm following the collMod index options in the documentation. I think this differs from validIndexOptions because collMod does not support every valid index option. I tried to collMod 2dsphereIndexVersion and got an IDLUnknownField error.
This commit fixes a bug that mongorestore only recognizes
hiddenandexpireAfterSecondsoptions in an index collMod oplog. The change allows mongorestore to pass any collMod index options to the restored index.